import 'package:base_lib/common/index.dart';
import 'package:base_lib/common/network/loading_dialog.dart';
import 'package:base_lib/router/routers.dart';
import 'package:base_lib/utils/screen_adapter.dart';
import 'package:doctor_login_lib/cache/userinfo_cache.dart';
import 'package:doctor_login_lib/component.dart';
import 'package:doctor_login_lib/login/entity/doctor_login_entity.dart';
import 'package:doctor_login_lib/repository/http.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class SplashPage extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return _SplashPageState();
  }
}

class _SplashPageState extends State<SplashPage>
    with SingleTickerProviderStateMixin, AfterLayoutMixin {
  // AnimationController controller;
  // Animation<double> animation;

  @override
  void initState() {
    super.initState();
    // controller = AnimationController(
    //     vsync: this, duration: Duration(milliseconds: 3500));
    // animation = Tween(begin: 0.24, end: 1.24).animate(controller)
    //   ..addStatusListener((status) {
    //     if (status == AnimationStatus.completed) {
    //       controller?.forward();
    //     }
    //   });
    //
    // controller?.forward();
  }

  @override
  void dispose() {
    super.dispose();
    // controller?.dispose();
  }

  @override
  Widget build(BuildContext context) {
    ScreenAdapter.getInstance().init(context);
    var width = MediaQuery.of(context).size.width;
    var height = MediaQuery.of(context).size.height;
    // return FadeTransition(
    // opacity: animation,
    // child:
    return Container(
      child: AspectRatio(
        aspectRatio: width / height,
        child: Image.asset(
          "images/splash.png",
          fit: BoxFit.fill,
        ),
      ),
    );
    // );
  }

  @override
  void afterFirstLayout(BuildContext context) {
    LoginHttp.createHttpProxy();
    DoctorLoginComponent.doAutoLogin(context);
  }
}
